<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>前端监控</title>
    <!-- <link rel="stylesheet" href=""> -->
  </head>
  <body>
    <div id="container">
      <div class="content">
        <input
          type="button"
          id="successBtn"
          value="ajax成功请求"
          onclick="sendSuccess()"
        />
        <input
          type="button"
          id="errorBtn"
          value="ajax失败请求"
          onclick="sendError()"
        />
      </div>
    </div>
    <script>
      function sendSuccess() {
        let xhr = new XMLHttpRequest();
        xhr.open("GET", "/success", true);
        xhr.responseType = "json";
        xhr.onload = function () {
          console.log(xhr.response);
        };
        xhr.send();
      }

      function sendError(params) {
        let xhr = new XMLHttpRequest();
        xhr.open("POST", "/error", true);
        xhr.responseType = "json";
        xhr.onload = function () {
          console.log(xhr.response);
        };
        xhr.onerror = function (err) {
          console.log(err);
        };
        xhr.send("name=lyy");
      }
    </script>
    <script src="error.js"></script>
  </body>
</html>
